* Clean up
clear all

/* Set working directory: please set your own
cd "~/Dropbox/JOP third submission/JOP replication/"
*/

* Open dataset
use 01_data/whole_spain.dta, clear

* Fake model to get the dataset started
reg pp_voteshare turnout 
regsave turnout using 01_data/other_outcomes.dta, ci replace addlabel (Outcome, fake, Model, 0) 

* Turnout
reghdfe turnout post##ep##ciutadella if period > 1, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Turnout, Model, Model 1)

* PSOE
reghdfe psoe_voteshare post##ep##ciutadella if period > 1, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, PSOE voteshare, Model, Model 1)

* Null votes
reghdfe null_share post##ep##ciutadella if period > 1, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Null votes, Model, Model 1)

* White votes
reghdfe white_share post##ep##ciutadella if period > 1, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, White votes, Model, Model 1)

* Turnout
reghdfe turnout post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Turnout, Model, Model 2)

* PSOE
reghdfe psoe_voteshare post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, PSOE voteshare, Model, Model 2)

* Null votes
reghdfe null_share post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Null votes, Model, Model 2)

* White votes
reghdfe white_share post##ep##ciutadella, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, White votes, Model, Model 2)

* Turnout
reghdfe turnout post##ep##ciutadella i.period, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Turnout, Model, Model 3)

* PSOE
reghdfe psoe_voteshare post##ep##ciutadella i.period, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, PSOE voteshare, Model, Model 3)

* Null votes
reghdfe null_share post##ep##ciutadella i.period, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, Null votes, Model, Model 3)

* White votes
reghdfe white_share post##ep##ciutadella i.period, absorb(mesa_code_elecspecific) cluster(mesa_code_elecspecific)
regsave 1.post#1.ep#1.ciutadella using 01_data/other_outcomes.dta, ci append addlabel (Outcome, White votes, Model, Model 3)
